import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import '../providers/theme_provider.dart';

class HealthProfilePage extends StatelessWidget {
  const HealthProfilePage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    final themeProvider = Provider.of<ThemeProvider>(context);

    return SingleChildScrollView(
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          // 用户信息卡片
          Padding(
            padding: const EdgeInsets.all(16.0),
            child: Card(
              elevation: 4,
              shape: RoundedRectangleBorder(
                borderRadius: BorderRadius.circular(16),
              ),
              child: Padding(
                padding: const EdgeInsets.all(16.0),
                child: Row(
                  children: [
                    CircleAvatar(
                      radius: 40,
                      backgroundColor: Theme.of(context).primaryColor,
                      child: const Icon(Icons.person,
                          size: 40, color: Colors.white),
                    ),
                    const SizedBox(width: 16),
                    Expanded(
                      child: Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: [
                          const Text(
                            '用户名',
                            style: TextStyle(
                              fontSize: 20,
                              fontWeight: FontWeight.bold,
                            ),
                          ),
                          const SizedBox(height: 8),
                          Text(
                            '欢迎使用健康助手',
                            style: TextStyle(
                              color: Colors.grey[600],
                            ),
                          ),
                        ],
                      ),
                    ),
                  ],
                ),
              ),
            ),
          ),

          // 设置部分
          Padding(
            padding: const EdgeInsets.all(16.0),
            child: Text(
              '设置',
              style: Theme.of(context).textTheme.titleLarge,
            ),
          ),

          // 主题设置
          ListTile(
            leading: const Icon(Icons.color_lens),
            title: const Text('主题设置'),
            trailing: Switch(
              value: themeProvider.isDarkMode,
              activeColor: Theme.of(context).primaryColor,
              onChanged: (_) {
                themeProvider.toggleTheme();
              },
            ),
            onTap: () {
              Navigator.pushNamed(context, '/theme_settings');
            },
          ),

          // 通知设置
          ListTile(
            leading: const Icon(Icons.notifications),
            title: const Text('通知设置'),
            onTap: () {
              // 导航到通知设置页面
            },
          ),

          // 语言设置
          ListTile(
            leading: const Icon(Icons.language),
            title: const Text('语言设置'),
            trailing: const Text('简体中文 >'),
            onTap: () {
              // 导航到语言设置页面
            },
          ),

          const Divider(),

          // 关于我们（集成到设置页面）
          ListTile(
            leading: const Icon(Icons.info),
            title: const Text('关于我们'),
            onTap: () {
              Navigator.pushNamed(context, '/about');
            },
          ),

          // 联系我们
          ListTile(
            leading: const Icon(Icons.email),
            title: const Text('联系我们'),
            onTap: () {
              // 显示联系方式
              showDialog(
                context: context,
                builder: (context) => AlertDialog(
                  title: const Text('联系方式'),
                  content: Column(
                    mainAxisSize: MainAxisSize.min,
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: const [
                      Text('开发者: 坚果派'),
                      Text('公众号: nutpi'),
                      Text('电话: 17752170152'),
                      Text('网站: https://www.nutpi.net'),
                    ],
                  ),
                  actions: [
                    TextButton(
                      onPressed: () => Navigator.of(context).pop(),
                      child: const Text('关闭'),
                    ),
                  ],
                ),
              );
            },
          ),

          // 退出登录按钮
          Padding(
            padding: const EdgeInsets.all(24.0),
            child: SizedBox(
              width: double.infinity,
              child: ElevatedButton(
                onPressed: () {
                  // 退出登录逻辑
                },
                style: ElevatedButton.styleFrom(
                  padding: const EdgeInsets.symmetric(vertical: 12),
                  shape: RoundedRectangleBorder(
                    borderRadius: BorderRadius.circular(8),
                  ),
                ),
                child: const Text('退出登录'),
              ),
            ),
          ),
        ],
      ),
    );
  }
}
